﻿namespace HRM.Update
{
    using ComponentAce.Compression.Archiver;
    using ComponentAce.Compression.ZipForge;
    using DevExpress.XtraEditors;
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.IO;
    using System.Runtime.CompilerServices;
    using System.Threading;
    using System.Windows.Forms;

    public class xfmOffProcess : XtraForm
    {
        private IContainer icontainer_0 = null;
        private LabelControl labelControl_0;

        private event Delegate0 ExtractFile;

        public event SuccessEventHander SuccessUpdate;

        public xfmOffProcess(string str)
        {
            this.method_0();
            this.ExtractFile = (Delegate0)Delegate.Combine(this.ExtractFile, new Delegate0(this.method_1));
            new Thread(new ParameterizedThreadStart(this.method_3)).Start(str);
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.icontainer_0 != null))
            {
                this.icontainer_0.Dispose();
            }
            base.Dispose(disposing);
        }

        public void InvokeSuccessUpdate(bool isSuccess)
        {
            SuccessEventHander hander = this.SuccessUpdate;
            if (hander != null)
            {
                hander(isSuccess);
            }
        }

        private void method_0()
        {
            this.labelControl_0 = new LabelControl();
            base.SuspendLayout();
            this.labelControl_0.Location = new Point(0x16, 11);
            this.labelControl_0.Name = "lbStatus";
            this.labelControl_0.Size = new Size(0, 13);
            this.labelControl_0.TabIndex = 0;
            base.AutoScaleMode = AutoScaleMode.None;
            base.ClientSize = new Size(0x15a, 0x22);
            base.ControlBox = false;
            base.Controls.Add(this.labelControl_0);
            this.DoubleBuffered = true;
            base.FormBorderStyle = FormBorderStyle.FixedDialog;
            base.MaximizeBox = false;
            base.MinimizeBox = false;
            base.Name = "xfmOffProcess";
            base.ShowInTaskbar = false;
            base.StartPosition = FormStartPosition.CenterScreen;
            base.TopMost = true;
            base.ResumeLayout(false);
            base.PerformLayout();
        }

        private void method_1(string string_0)
        {
            if (this.labelControl_0.InvokeRequired)
            {
                Delegate0 method = new Delegate0(this.method_1);
                base.Invoke(method, new object[] { string_0 });
            }
            else
            {
                this.labelControl_0.Text = string_0;
            }
        }

        private void method_2(string string_0)
        {
            Delegate0 delegate2 = this.ExtractFile;
            if (delegate2 != null)
            {
                delegate2(string_0);
            }
        }

        private void method_3(object object_0)
        {
            ComponentAce.Compression.ZipForge.ZipForge forge = new ComponentAce.Compression.ZipForge.ZipForge();
            try
            {
                forge.FileName = object_0 as string;
                forge.OpenArchive(FileMode.Open);
                forge.OnFileProgress += new BaseArchiver.OnFileProgressDelegate(this.method_4);
                forge.BaseDir = Application.StartupPath;
                forge.ExtractFiles("*.*");
                forge.CloseArchive();
                this.method_2("... Cập nhập ho\x00e0n th\x00e0nh.");
                Thread.Sleep(0x7d0);
                base.Close();
                this.InvokeSuccessUpdate(true);
            }
            catch (ArchiverException exception)
            {
                MessageBox.Show(string.Concat(new object[] { "Message: ", exception.Message, "\t Error code: ", exception.ErrorCode }));
                Application.Exit();
            }
        }

        private void method_4(object object_0, string string_0, double double_0, TimeSpan timeSpan_0, TimeSpan timeSpan_1, ProcessOperation processOperation_0, ProgressPhase progressPhase_0, ref bool bool_0)
        {
            Thread.Sleep(200);
            this.method_2("... " + string_0 + " >> " + double_0.ToString("f2") + "%");
        }

        private delegate void Delegate0(string str);

        public delegate void SuccessEventHander(bool isSuccess);
    }
}

